Python Data types are an essential part of the Python programming language. Python has built-in data types that we can use to store different kinds of information.
The default most common data types are:
- Strings:
type: str
- An ordered sequence of characters wrapped in single, double or triple quotes
'the cat is blue' '45.23' "The dog is here and there" '''This is How to do a multi-line string'''
- Integers:
type: int
- Whole numbers
5 4 12 -56
- Floats:
type: float
- Floating point numbers
45.12 12.0 124.41 -123.53
- Lists:
type: list
- An ordered sequence of objects wrapped in square brackets
[1,2,3] ['cat', 'dog', 5] [45.4, 12, '24']
- Dictionaries:
type: dict
- An unordered set of key/value pairs wrapped in curly brackets
- {‘key1’: 1, ‘key2’:2}
- Tuples
type: tup
- An ordered sequence of immutable objects wrapped in round brackets
- (‘apple’, 5, ‘cat’)
- Sets
type: set
- An unordered collection of unique objects wrapped in curly brackets
- {‘blue’,2,”cat”,4}
- Booleans:
type: bool
- A logical value indicating true or false
We will explore integers and floats in more detail in the next post!